<?php 
session_start();

require('../../functions.php');
require('../../db.php');


/***** PROCESS FOR QUICK ADD EVENT *****/

/*$qk_mn = filter_var($_POST['qk_mn'], FILTER_SANITIZE_STRIPPED);
$qk_type = filter_var($_POST['assignmnt'], FILTER_SANITIZE_STRIPPED);
$qk_date = filter_var($_POST['qk_date'], FILTER_SANITIZE_NUMBER_INT);
$qk_location = filter_var($_POST['qk_loc'], FILTER_SANITIZE_STRIPPED);*/

$qk_evnts = array(
	"mn" => filter_input(INPUT_POST, 'qk_mn', FILTER_SANITIZE_STRIPPED),
	"type" => filter_input(INPUT_POST, 'qk_assignmnt', FILTER_SANITIZE_STRIPPED),
	"date" => filter_input(INPUT_POST, 'qk_date', FILTER_SANITIZE_NUMBER_INT),
	"location" => filter_input(INPUT_POST, 'qk_loc', FILTER_SANITIZE_STRIPPED)
);

/*echo "<pre>";
	var_dump($qk_evnts);
echo "</pre>";*/


if(!in_array("", $qk_evnts)) {

	$qk = $db->prepare(
		"INSERT INTO cal (id_users, model_name, assignment, date, location)
		VALUES (:uid, :mn, :type, :date, :location)
		");

	$param = array(
		':uid' => $_SESSION['user_id'],
		':mn' => $qk_evnts['mn'],
		':type' => $qk_evnts['type'],
		':date' => $qk_evnts['date'],
		':location' => $qk_evnts['location']
	);

	$qk->execute($param);

	//echo "the data was passed.. <a href='../wschedule2.php'>go back</a>";


	/*print "<pre>";
		print_r($qk_wkcal_info);
	print "</pre>";*/

	//data passed, redirect to main wk cal page with confirmation that data was added
	redirect("../wschedule2.php?evnt_added=1");

} else {

	//tell me what the errors are in the db...
	/*print "<pre>";
		var_dump($qk->errorInfo());
	print "</pre>";*/


	//also...
	print "ey, check one of these... something is wrong <br />";
	print "<pre>";
		print_r($qk_evnts);
	print "</pre>";

	//data failed.. theres a problem
	//redirect("../wschedule2.php?evnt_error=1");

}

//dont need these for now...
/*else {
	print "ey, check one of these... something is wrong <br />";
	print "<pre>";
		print "model name <br />";
		print_r($qk_mn);
		print "type <br />";
		print_r($qk_type);
		print "date <br />";
		print_r($qk_date);
		print "location <br />";
		print_r($qk_location);
	print "</pre>";
}*/
